}
+/*
+ *Check is the address where NVRAM data located valid
+ */
+static int is_valid_address(void *addr)
+{
+ struct nvram_save_addr *p = (struct nvram_save_addr *)addr;
+
+ if ( p->signature == NVRAM_VALID_SIG )
+ return 1;
+ else {
+ PERROR("Invalid nvram signature. Nvram save failed!\n");
+ return 0;
+ }
+}
+
/*
* GFW use 4k page. when doing foreign map, we should 16k align
* the address and map one more page to guarantee all 64k nvram data
return -1;
}
- addr_from_GFW_4k_align = *((uint64_t *)tmp_ptr);
+ /* Check is NVRAM data vaild */
+ if ( !is_valid_address(tmp_ptr) )
+ return -1;
+
+ addr_from_GFW_4k_align = ((struct nvram_save_addr *)tmp_ptr)->addr;
munmap(tmp_ptr, PAGE_SIZE);
// align address to 16k
#define NVRAM_SIZE (MEM_K * 64)
#define NVRAM_START (GFW_START + 10 * MEM_M)
+#define NVRAM_VALID_SIG 0x4650494e45584948 // "HIXENIPF"
+struct nvram_save_addr {
+ unsigned long addr;
+ unsigned long signature;
+};
+
struct pt_fpreg {
union {
unsigned long bits[2];